import * as ws from 'ws';
import { Log } from './Log';

export class SocketServer
{
    private _wss:ws.Server;
    private _sessions:Array<Session>;

    constructor()
    {
        this._sessions = new Array<Session>();
    }

    public init(port:number):void
    {
        this._wss = new ws.Server({port:port});
        Log.log('websocket linsten on:',port);
        let self = this;

        this._wss.on('connection',function(ws,req){
            Log.log('url:',req.url);
            
            self._sessions.push();
        });
    }
}


/**session通过acc和ip区分不同的session */
class Session
{
    public ws:ws;
    public ip:string;
    public acc:string;
}